Skip to content

Conversation

@rjrios915
Copy link
Contributor

@rjrios915 rjrios915 commented Aug 27, 2024

Addresses #126

Added option to specify cardiac period under simulation parameters

Current situation

Link any open issues or PRs related to this PR. Please ensure that all non-trivial PRs are first tracked and discussed in an existing GitHub issue or discussion.

Release Notes

Add a bullet point list summary of the feature and possible migration guides if this is a breaking change so this section can be added to the release notes.

Documentation

Please ensure that you properly document any additions.

Testing

Please ensure that the PR meets the testing requirements set by GitHub Actions.

In addition, please ensure all modified and new code is covered by tests.

Code of Conduct & Contributing Guidelines

@menon-karthik
Copy link
Member

@rjrios915 @JonathanPham Please make sure the tests are passing!

Also, just wondering if it might be better to specify the cardiac cycle period within the relevant block that is driving the cardiac cycle (like the cardiac chamber)? For example, the currently implemented ClosedLoopHeartPulmonary block has this implemented within the block. It might make more sense to do this because the cycle period is not a parameter of the entire simulation really, it is only a parameter of the block that is driving the heart beat.

@menon-karthik
Copy link
Member

@rjrios915 @JonathanPham Not sure why the tests are still failing but can you rebase this branch with the master so it it using the most recent version please?

@rjrios915
Copy link
Contributor Author

Hello! All test cases except the data visualization should now be passing. As for where the cardiac period is defined, I think it could be useful to do so globally. The solver already utilizes a global period to calculate step size, number of cycles, and the time per cycle when outputting a single cardiac cycle even when there is no heart block, so I was thinking adding it to simulation parameters would make it easy for users to change the value if needed.

Copy link
Member

@menon-karthik menon-karthik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjrios915 We should make sure your changes are consistent with what the code is currently doing. I have commented on specific changes and added links to where they might be inconsistent with the current code. Here's a quick summary:

Currently, model->cardiac_cycle_period is initialized as -1.0 here:

double cardiac_cycle_period = -1.0; ///< Cardiac cycle period

model->cardiac_cycle_period remains -1.0 until it is specified by a block, at which point we make sure that the newly specified value matches the value read previously from any other block (if any). I have provided examples of how that is checked in my comments below.

If no value has been specified after all blocks have been read, a default value of 1.0 is set. This is in Model::finalize and I have also provided a link to that code block in my comments below.

Please make sure your current changes are consistent with that. Mainly, the default should be 1.0 and you should check that any newly specified value is consistent with previously specified values (if any).

@rjrios915
Copy link
Contributor Author

rjrios915 commented Oct 22, 2024

Hello! We ran into the issue where the initialization of cardiac period to 1 within the model and simulation parameters separately cause an error when one would automatically be 1 but the other some valid non 1 value. To resolve this, both the model and parameters initialize the cardiac period to -1 unless specified elsewhere. If both values are -1, then solver.h sets the value to 1 (like what was happening in Model::Finalize). If both values are larger than 0, there is a check to make sure the values are consistent. If one is -1 and the other is greater than 0, then that value is set as the cardiac cycle.

The other idea we had was to pass the parameters to the model constructor so this process could happen like originally when the model is initialized, but I was unsure of how to go about this.

Let me know your thoughts! All the tests should be passing.

@ncdorn
Copy link
Contributor

ncdorn commented Oct 30, 2024

@rjrios915 ensure that documentation for cardiac period has been added

@mrp089
Copy link
Member

mrp089 commented Feb 6, 2025

What else needs to be done to merge this (if we still want to merge it)?

@ncdorn
Copy link
Contributor

ncdorn commented Mar 5, 2025

We do still want to merge this. I will meet with @rjrios915 this week to finalize. Ricky - are all the tests passing and do we still need to address karthik's earlier comments?

@mrp089
Copy link
Member

mrp089 commented Mar 14, 2025

You can format your code automatically, e.g., in VS Code: https://code.visualstudio.com/docs/cpp/cpp-ide

@ncdorn
Copy link
Contributor

ncdorn commented Mar 19, 2025

all tests are passing here - @menon-karthik are we good to merge this? There was a new test case added to make sure we are catching mismatched cardiac period errors, maybe you want to look over that quickly.

@ncdorn
Copy link
Contributor

ncdorn commented Mar 27, 2025

still need 1 more review on this to merge it I think

@ncdorn
Copy link
Contributor

ncdorn commented Jun 10, 2025

@rjrios915 It appears that this branch got mixed up with the branch in #168

Copy link
Contributor

@ncdorn ncdorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ncdorn ncdorn dismissed menon-karthik’s stale review June 24, 2025 18:47

This is now an outdated review, and the changes were addressed.

@ncdorn
Copy link
Contributor

ncdorn commented Jun 24, 2025

@mrp089 do you want to review this before we merge?

@ncdorn
Copy link
Contributor

ncdorn commented Jun 26, 2025

@mrp089 do you care if we merge this before or after #176

@ncdorn ncdorn requested a review from mrp089 July 24, 2025 16:10
mrp089
mrp089 previously requested changes Jul 31, 2025
Copy link
Member

@mrp089 mrp089 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: exclude your changes in the .github folder from this PR.

Apart from that, it looks good to me. It would be good to document the new option. Unfortunately, I have no idea where to put that after the documentation was moved away from this repository. I'll let @ktbolt sort that out.

@ktbolt
Copy link
Contributor

ktbolt commented Jul 31, 2025

@mrp089 The important thing is that users can now find the documentation !

I think most SimVascular developers have updated the web documentation, very easy to do in fact.

@ncdorn ncdorn dismissed mrp089’s stale review September 23, 2025 18:51

Ricky has addressed these changes

@ncdorn ncdorn merged commit 85ccad5 into SimVascular:master Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants